package gnar.euler.math
import scala.collection.mutable.ListBuffer

object Fib {

  def genFibList(size: Int): ListBuffer[Int]= {
    val fibList = new ListBuffer[Int]
    val iter = fibs.iterator
    var tmp = 0
    while (tmp < size){
      fibList += tmp 
      tmp = iter.next()
    }
    fibList
  }
  
  lazy val fibs = {
    def f(a:Int,b:Int):Stream[Int] = a #:: f(b,a+b)
    f(0,1)
  }
}